
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
    <link href="${pageContext.request.contextPath}/static/css/bootstrap.min.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/static/js/jquery-2.1.0.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
    <style type="text/css">
        td, th {
            text-align: center;
        }
    </style>

    <script>
       $(function () {
            /* $("#deleteComments").click(function () {
                if (confirm("确定要删除吗？")){
                    location.href = "${pageContext.request.contextPath}/myself/deleteComments";
                }
            });

            $("#deleteCollect").click(function () {
                if (confirm("确定要取消吗？")){
                    location.href = "${pageContext.request.contextPath}/myself/cancelCollect";
                }
            });*/



            //给删除按钮添加点击事件
            $("#deleteSelect").click(function (){
                var selectFlag = false;
                if(confirm("确定要删除选中的评论吗?")){
                    $("#commentsform").attr("action","${pageContext.request.contextPath}/myself/deleteAll");
                    var cbs=document.getElementsByName("selected");
                    for (var i=0;i<cbs.length;i++){
                        if (cbs[i].checked){
                            selectFlag = true;
                            break;
                        }
                    }

                }
                if(selectFlag){
                    $("#commentsform").submit();
                }
            });

           //给取消按钮添加点击事件
           $("#deleteSelectCollect").click(function (){
               var selectFlag = false;
               if(confirm("确定要取消选中的收藏吗?")){
                   $("#collectform").attr("action","${pageContext.request.contextPath}/myself/cancelAll");
                   var cbs=document.getElementsByName("collectselected");
                   for (var i=0;i<cbs.length;i++){
                       if (cbs[i].checked){
                           selectFlag = true;
                           break;
                       }
                   }

               }
               if(selectFlag){
                   $("#collectform").submit();
               }
           });

            $("#controlAll").click(function () {
                var flag = $(this).prop("checked");
                $(".selected").prop("checked",flag);
            });

            $("#collectControlAll").click(function () {
                var flag = $(this).prop("checked");
                $(".collectselected").prop("checked",flag);
            });

        });
    </script>

</head>
<body>
<c:import url="component/header.jsp"></c:import>

<table id="myselfmsg" class="myselfmsg" align="center">
    <tr>
        <td><h3>${sessionScope.user.username}</h3></td>
        <td><a href="${pageContext.request.contextPath}/myself/toUpdate">修改个人信息</a></td>
    </tr>
    <tr>
        <td>邮箱:</td>
        <td>${sessionScope.user.email}</td>
    </tr>
    <tr>
        <td>姓名:</td>
        <td>${sessionScope.user.name}</td>
    </tr>
    <tr>
        <td>禁言状态:</td>
        <td>${sessionScope.user.banned}</td>
    </tr>
    <tr>
        <td>关注:</td>
        <td>${sessionScope.myAttentionNum}</td>
    </tr>
</table>
    <%--评论--%>
<div class="container">
    <h3 style="text-align: left">我的评论</h3>
    <div style="float: left">
        <form class="form-inline" action="${pageContext.request.contextPath}/myself/selectAnimation" id="selectform" method="post">
            <div class="form-group">
                <label for="selectname">动漫名</label>
                <input type="text" class="form-control" id="selectname" name="selectname" placeholder="查询所有" value="查询所有" >
            </div>
            <button type="submit" class="selectbutton">查询</button>
        </form>
    </div>
    <div style="float: right">
        <tr>
            <td colspan="8" align="center"><a class="btn btn-primary" href="#" id="deleteSelect">删除选中</a></td>
        </tr>
    </div>

    <%--    删除选中：添加form表单标签--%>
    <form action="#" method="post" id="commentsform">
        <table border="1" class="table table-bordered table-hover">
            <tr class="success"  style="background: red">
                <th>
                    <input type="checkbox"  name="controlAll" id="controlAll">
                </th>
                <th>封面</th>
                <th>动漫名</th>
                <th>评论内容</th>
                <th>创建时间</th>
                <th>点赞数</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${sessionScope.commentsList}" var="list" varStatus="s">
                <tr>
                    <td>
                        <input type="checkbox" class="selected" name="selected" id="selected" value="${list.commentsDO.com_id}">
                    </td>
                    <td><img src="${pageContext.request.contextPath}/${list.animationSimpleDO.cover_img}" alt="图片正在加载..." height="50"></td>
                    <td>${list.animationSimpleDO.aname}</td>
                    <td>${list.commentsDO.context}</td>
                    <td>${list.commentsDO.create_time}</td>
                    <td>${list.commentsDO.like_num}</td>
                    <td><%--<a class="btn btn-default btn-sm" href="#">修改评论</a>&nbsp;--%>
                        <a class="btn btn-default btn-sm" id="deleteComments" href="${pageContext.request.contextPath}/myself/deleteComments">删除评论</a></td>
                </tr>

           </c:forEach>

        </table>
    </form>

</div>
<%--收藏collect--%>

<div class="container">
    <h3 style="text-align: left">我的收藏</h3>
    <div style="float: left">
        <form class="form-inline" action="${pageContext.request.contextPath}/myself/selectCollect" id="selectCollectform" method="post">
            <div class="form-group">
                <label for="selectname">动漫名</label>
                <input type="text" class="form-control" id="selectCollectname" name="selectCollectname" placeholder="查询所有" value="查询所有" >
            </div>
            <button type="submit" class="selectbutton">查询</button>
        </form>
    </div>
    <div style="float: right">
        <tr>
            <td colspan="8" align="center"><a class="btn btn-primary" href="#" id="deleteSelectCollect">取消收藏</a></td>
        </tr>
    </div>

   <%--删除选中：添加form表单标签--%>
    <form action="#" method="post" id="collectform">
        <table border="1" class="table table-bordered table-hover">
            <tr class="success">
                <th>
                    <input type="checkbox"  name="collectControlAll" id="collectControlAll">
                </th>
                <th>封面</th>
                <th>动漫名</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${sessionScope.collectList}" var="clist" varStatus="s">
                <tr>
                    <td>
                        <input class="collectselected" type="checkbox" name="collectselected" id="collectselected" value="${clist.animationSimple.aid}">
                    </td>
                    <td><img src="${pageContext.request.contextPath}/${clist.animationSimple.cover_img}" alt="图片正在加载..." height="50"></td>
                    <td>${clist.animationSimple.aname}</td>
                    <td>
                        <a class="btn btn-default btn-sm" id="deleteCollect" href="${pageContext.request.contextPath}/myself/cancelCollect">取消收藏</a></td>
                </tr>

            </c:forEach>

        </table>
    </form>
</div>
</body>
</html>
